﻿using System;
using System.Drawing;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using SenseTimeTracker.BusinessLayer;
using StedySoft.SenseSDK;

namespace SenseTimeTracker.Tasks
{
	public class TaskDisplayItem : CommonSenseControls.CommonSenseDisplayPanelItem
	{
		private Task task;
		//private Guid taskId = Guid.Empty;
		//private string taskNumber = string.Empty;
		//private string taskName = string.Empty;

		public TaskDisplayItem()
		{
			Height = 50;
		}

		public Task Task
		{
			get { return task; }
			set { task = value; }
		}

		#region ISenseListItem Members

		public override void OnRender(Graphics g)
		{
			using (Brush brush = new SolidBrush(Color.Black))
			using (Brush selecteionBrush = new SolidBrush(Color.Gray))
			using (Font primaryFont = new Font("Helvetica Neue OTS", 9f, FontStyle.Regular))
			using (Font secondaryFont = new Font("Helvetica Neue OTS", 7f, FontStyle.Regular))
			{
				if (selected)
				{
					g.FillRectangle(selecteionBrush, ClientRectangle);
				}
				string taskName = task.Name;
				if (task.TerpExportLocation)
				{
					taskName += " " + task.Location;
				}
				SizeF taskNameTextSize = g.MeasureString(taskName, primaryFont);
				g.DrawString(taskName, primaryFont, brush, ClientRectangle.Left + 8, ClientRectangle.Top + ClientRectangle.Height * 1 / 4 - taskNameTextSize.Height / 2);
				SizeF taskNumberTextSize = g.MeasureString(task.Number, secondaryFont);
				g.DrawString(task.Number, secondaryFont, brush, ClientRectangle.Left + 8, ClientRectangle.Top + ClientRectangle.Height * 3 / 4 - taskNumberTextSize.Height / 2);
			}

			base.OnRender(g);
		}

		#endregion
	}
}
